package cn.ibdsr.human.warpper;

import cn.ibdsr.human.common.factory.ConstantFactory;
import cn.ibdsr.human.constant.GenderEnum;
import cn.ibdsr.human.constant.JwtConstants;
import com.alibaba.fastjson.JSONObject;

import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: cdl
 * @email: iamcimon@qq.com
 * @date: 2021/8/3 14:26
 */
public class UserDetailWarpper extends BaseControllerWarpper {

    private  Boolean IS_NULL=false;

//    public UserDetailWarpper(JSONObject jsonObject) {
//
//        super(jsonObject);
//        this.IS_NULL=false;
//    }

    public UserDetailWarpper(JSONObject jsonObject,Boolean is_null) {
        super(jsonObject);
        this.IS_NULL=is_null;
    }


    @Override
    protected void warpTheMap(Map<String, Object> var1) {

        if( var1.get("gender")==null){

            var1.put("genderDes", this.IS_NULL?null:JwtConstants.NO_LIMIT);
        }else {
            var1.put("genderDes", GenderEnum.valueOf(Integer.valueOf((Integer) var1.get("gender"))).getDesc());
        }
        if (var1.get("politic") == null) {
            var1.put("politicDes",this.IS_NULL?null:JwtConstants.NO_LIMIT);
        } else {
            var1.put("politicDes", ConstantFactory.me().getPolitic(
                    Integer.valueOf((Integer) var1.get("politic")),this.IS_NULL
            ));
        }
        if (var1.get("education") == null) {
            var1.put("educationDes", this.IS_NULL?null: JwtConstants.NO_LIMIT);
        } else {
            var1.put("educationDes", ConstantFactory.me().getEducation(
                    Integer.valueOf((Integer) var1.get("education")),this.IS_NULL
            ));
        }

        if (var1.get("married") == null) {
            var1.put("marriedDes", this.IS_NULL?null:JwtConstants.NO_LIMIT);
        } else {
            var1.put("marriedDes", ConstantFactory.me().getMarried(

                    Integer.valueOf((Integer) var1.get("married")),this.IS_NULL
            ));

        }

        if (var1.get("experience") == null) {
            var1.put("experienceDes",this.IS_NULL?null:JwtConstants.NO_LIMIT);
        } else {
            var1.put("experienceDes", ConstantFactory.me().getExperience(
                    Integer.valueOf((Integer) var1.get("experience")),this.IS_NULL
            ));
        }
    }
}
